<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<script type="text/javascript">
	   $(document).ready(function(){
	        $.formValidator.initConfig({formid:"portlet2form",alertmessage:false,onerror:function(msg){alert(msg)}});
			$("#productgroupid").formValidator().inputValidator({min:1,onerror:"必须选择一个产品分类"});
			$("#assoportlet").formValidator({empty:"true"}).inputValidator({min:0,max:50,onerror:"无效的PortletID"});
	        
	        $("#productcount").formValidator().inputValidator({min:1,max:100,type:"value",onerror:"显示产品数量必须是1-100之间的数字"});
            $("#titlelength").formValidator().inputValidator({min:1,max:500,type:"value",onerror:"显示产品标题长度必须是1-500之间的数字"});
            $("#summarylength").formValidator().inputValidator({min:1,max:500,type:"value",onerror:"产品介绍长度必须是1-500之间的数字"});
            
            $("#title").formValidator({empty:"true"}).inputValidator({min:1,max:250,onerror:"portlet名称过长"});
            $("#portletwidth").formValidator().inputValidator({min:0,max:1500,type:"value",onerror:"portlet宽度必须是0-1500之间的数组"});
            $("#portletheight").formValidator().inputValidator ({min:0,max:5000,type:"value",onerror:"portlet高度必须是0-5000之间的数组"});
	  });

	  var save = function(){
			var flag = "failure";
			if($.formValidator.pageIsValid()){
				var options = {
					type: 'POST',
					async: false,
					dataType: 'content-type',
					success: function(msg) {
						flag = "success";
					}
				}
				$('#portlet2form').ajaxSubmit(options);
			}
			return flag;
	}
		
	function selchannel(oId,oName){
			$('<iframe src="<%=path %>/ext/products/get/selGrpIndex?oId='+oId+'&oName='+oName+'" />').dialog({
                title: '选择产品分类',
                autoOpen: true,
                width: 300,
                height: 200,
                modal: true,
	            buttons: {
					"确定": function() {
						var retv = this.contentWindow.getChannels();
						if(retv.split("$")[0] =="ROOT"){
							alert("不能选择根分类");
							$(this).dialog( "close" );
						}
						document.getElementById(oId).value=retv.split("$")[0];
						document.getElementById(oName).value=retv.split("$")[1];
						$(this).dialog( "close" );
					},
					"关闭": function() {
						$(this).dialog( "close" );
					}
				}  
            }).width(300).height(200);
	}
	function selectColor(){
            opendailog("{src:'<%=path %>/resources/component/farbtastic/demo1.jsp?color="+$('#titlecolor').val().substring(1,$('#titlecolor').val().length)+"',title:'选取颜色',width:320,height:300,savefunc:'savefunc1'}",window);
	}
	
	function savefunc1(frame){
		var retv = frame.contentWindow.save();
		$('#titlecolor').val(retv);
		return "success";
	}
	
	function selectImage(){
		opendailog("{src:'<%=path %>/res/get/selectImageIndex',title:'选取图片',width:600,height:400,savefunc:'savefunc2'}",window);
	}
	function savefunc2(frame){
		var retv = frame.contentWindow.save();
		if(retv){
			$('#titlepic').val(retv);
			return "success";		
		}
	}
</script>
<form id="portlet2form"  action="<%=path%>/cms/portlet/saveportlet2" method="post" target="_self">
<table><tr><td height="2px"></td></tr></table>
<table align="center" border="0" cellpadding="0" cellspacing="1" class="table_nbw" >
	<thead class="th_nbw">
	<tr>
		<td colspan="2" align="center"><strong>产品展现设置 ${portlet2.id}</strong></td>
	</tr>
	</thead>
	<tr >
	<td align="right" width="40%"  style="background-color:fff;height:25px;">产品分类</td>
		<td align="left" style="background-color:fff">
			<input class="textfiled_nbw"  type="text" id="showprogrpTitle" readonly="readonly" name="showprogrpTitle" value="${portlet2.showprogrpTitle}">
			<input type="hidden" id="productgroupid" name="productgroupid" value="${portlet2.productgroupid}">
			<input type="button" value="选择" onclick="selchannel('productgroupid','showprogrpTitle')"/>
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">是否导航</td>
		<td align="left" style="background-color:fff">&nbsp;
			<input type="radio" value="0" checked="checked" name="isnavi" />否
			&nbsp;&nbsp;&nbsp;&nbsp; 
			<input type="radio" value="1" ${portlet2.isnavi==1?'checked=checked':''} name="isnavi" />是
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">导航展示层次</td>
		<td align="left" style="background-color:fff">&nbsp;
			<select name="showlevel" style="width:80">
				<option value="1" ${'1'==portlet2.showlevel?'selected':''}>1</option>
				<option value="2" ${'2'==portlet2.showlevel?'selected':''}>2</option>
				<option value="3" ${'3'==portlet2.showlevel?'selected':''}>3</option>
				<option value="4" ${'4'==portlet2.showlevel?'selected':''}>4</option>
			</select>
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">关联文章portlet</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="assoportlet" name="assoportlet" value="${portlet2.assoportlet}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">产品数量</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="productcount" name="productcount" value="${portlet2.productcount}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">产品名称长度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="titlelength" name="titlelength" value="${portlet2.titlelength}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">产品介绍长度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="summarylength" name="summarylength" value="${portlet2.summarylength}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">显示模板</td>
		<td align="left" style="background-color:fff">&nbsp;
			<select name="templateid" style="width:120">
			<c:forEach var="template" items="${templateList}"> 
				<option value='${template.id}' ${template.id==portlet2.templateid?'selected':''}>
					${template.name}
				</option> 
			</c:forEach> 
			</select>
		</td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">portlet名称</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="title" name="title" value="${portlet2.title}"></td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">portlet名称展示类型</td>
		<td align="left" style="background-color:fff">&nbsp;
			<label><input type="radio" value="0" checked="checked" name="titletype" />样式</lable>
			&nbsp;&nbsp;&nbsp;&nbsp; 
			<label><input type="radio" value="1" ${portlet2.titletype=="1"?'checked=checked':''} name="titletype" />图片</label>
		</td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">portlet名称样式</td>
		<td align="left" style="background-color:fff">&nbsp;
			<select name="titlecolor" style="width:120">
				<option value='portal_title1' ${portlet2.titlecolor=='portal_title1'?'selected':''}>标题1</option> 
				<option value='portal_title2' ${portlet2.titlecolor=='portal_title2'?'selected':''}>标题2</option> 
				<option value='portal_title3' ${portlet2.titlecolor=='portal_title3'?'selected':''}>标题3</option> 
				<option value='portal_title4' ${portlet2.titlecolor=='portal_title4'?'selected':''}>标题4</option> 
				<option value='portal_title5' ${portlet2.titlecolor=='portal_title5'?'selected':''}>标题5</option> 
				<option value='portal_title6' ${portlet2.titlecolor=='portal_title6'?'selected':''}>标题6</option> 
			</select>
		</td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">portlet名称图片</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="titlepic" name="titlepic" value="${portlet2.titlepic}">
			<input type = "button"  value = "选择"  onclick = "selectImage();">
		</td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">portlet长度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="portletwidth" name="portletwidth" value="${portlet2.portletwidth}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">portlet高度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="portletheight" name="portletheight" value="${portlet2.portletheight}"></td>
	</tr>

</table>
<input type=hidden name="id" value="${portlet2.id}" />
<input type=hidden name="showstate" value="1" />
<input type="hidden" id="portletype" name="portletype" value="product">
<input type="hidden" name="horderChannelId" value="${param.horderChannelId}"/>
<input type="hidden" name="placeholderId" value="${param.placeholderId}"/>
</form>


